using JRO;
using System;
using System.Collections;
using System.Data;
using System.Data.OleDb;
using System.IO;
using System.Text;
public class QQTaokeUtil
{
	public OleDbCommand oleDbCommand_0;
	private OleDbCommand oleDbCommand_1;
	private OleDbCommand oleDbCommand_2;
	private OleDbCommand oleDbCommand_3;
	private OleDbCommand oleDbCommand_4;
	public OleDbCommand oleDbCommand_5;
	private OleDbConnection oleDbConnection_0;
	private string string_0;
	private string string_1;
	public QQTaokeUtil()
	{
		this.string_0 = Directory.GetCurrentDirectory();
		this.oleDbCommand_4 = null;
		this.string_1 = this.string_0 + "\\config\\其他数据库.mdb";
		this.method_0();
	}
	public QQTaokeUtil(string string_2)
	{
		this.string_0 = Directory.GetCurrentDirectory();
		this.oleDbCommand_4 = null;
		this.method_1(string_2);
	}
	public void method_0()
	{
		this.method_1(this.string_1);
	}
	public void method_1(string string_2)
	{
		this.method_11(string_2);
		if (this.oleDbConnection_0 == null)
		{
			string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" + string_2 + ";Jet OLEDB:Database Password=other(*)135";
			this.oleDbConnection_0 = new OleDbConnection(connectionString);
			this.oleDbConnection_0.Open();
		}
	}
	public void method_10(out string string_2)
	{
		try
		{
			string string_3 = "Select Name FROM MsysObjects Where flags=0 AND (MSysObjects.Type)=1 orDER BY MSysObjects.Name";
			this.oleDbCommand_5 = this.method_8(this.oleDbCommand_5, string_3);
			OleDbDataReader oleDbDataReader = this.oleDbCommand_5.ExecuteReader();
			while (oleDbDataReader.Read())
			{
				string str = (string)oleDbDataReader["Name"];
				string string_4 = "drop table " + str;
				this.method_7(string_4, out string_2);
			}
			oleDbDataReader.Close();
			oleDbDataReader.Dispose();
			string_2 = "";
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
		}
	}
	public void method_11(string string_2)
	{
		try
		{
			if (!File.Exists(string_2))
			{
				string sourceFileName = this.string_0 + "\\config\\淘清仓淘抢购.mdb";
				string text = this.string_0 + "\\config\\temp.mdb";
				File.Copy(sourceFileName, text, false);
				string sourceConnection = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" + text + ";Jet OLEDB:Database Password=taoqq<#>678";
				string destconnection = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source=" + string_2 + ";Jet OLEDB:Database Password=other(*)135";
				new JetEngineClass().CompactDatabase(sourceConnection, destconnection);
				File.Delete(text);
			}
		}
		catch
		{
		}
	}
	public void method_12()
	{
		if (!File.Exists(this.string_1))
		{
			throw new Exception("目标数据库不存在,无法压缩");
		}
		try
		{
			this.oleDbConnection_0.Close();
			this.oleDbConnection_0.Dispose();
			this.oleDbConnection_0 = null;
			string text = "aliodr" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".bak";
			text = this.string_1.Substring(0, this.string_1.LastIndexOf("\\") + 1) + text;
			string destconnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + text + ";Jet OLEDB:Database Password=ali(*)135";
			string sourceConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + this.string_1 + ";Jet OLEDB:Database Password=ali(*)135";
			new JetEngineClass().CompactDatabase(sourceConnection, destconnection);
			File.Copy(text, this.string_1, true);
			File.Delete(text);
		}
		catch
		{
		}
		finally
		{
			this.method_0();
		}
	}
	public bool method_2(string string_2, out string string_3)
	{
		bool result;
		try
		{
			this.method_5(out string_3);
			string text = "INSERT INTO taokeqq(qq) VALUES ('{qq}');";
			text = text.Replace("{qq}", string_2);
			this.oleDbCommand_0 = this.method_8(this.oleDbCommand_0, text);
			this.oleDbCommand_0.ExecuteNonQuery();
			string_3 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_3 = "出错啦！" + ex.ToString();
			this.method_9();
			result = false;
		}
		return result;
	}
	public bool method_3(string qq, out string out_log)
	{
		bool result;
		try
		{
			this.method_5(out out_log);
			string string_ = "select qq from taokeqq where qq = '" + qq + "'";
			this.oleDbCommand_1 = this.method_8(this.oleDbCommand_1, string_);
			OleDbDataReader oleDbDataReader = this.oleDbCommand_1.ExecuteReader();
			if (oleDbDataReader.Read())
			{
				oleDbDataReader.Close();
				out_log = "";
				result = true;
			}
			else
			{
				oleDbDataReader.Close();
				out_log = "";
				result = false;
			}
		}
		catch (Exception ex)
		{
			out_log = "出错啦：" + ex.ToString();
			this.method_9();
			result = false;
		}
		return result;
	}
	public ArrayList method_4(ArrayList arrayList_0, out string string_2)
	{
		ArrayList result;
		try
		{
			StringBuilder stringBuilder = null;
			foreach (QQItem qQItem in arrayList_0)
			{
				if (stringBuilder == null)
				{
					stringBuilder = new StringBuilder();
					stringBuilder.Append("'" + qQItem.uin + "'");
				}
				else
				{
					stringBuilder.Append(", '" + qQItem.uin + "'");
				}
			}
			string string_3 = "select qq from taokeqq where qq in ( " + stringBuilder.ToString() + " )";
			this.method_5(out string_2);
			new ArrayList();
			this.oleDbCommand_2 = this.method_8(this.oleDbCommand_2, string_3);
			OleDbDataReader oleDbDataReader = this.oleDbCommand_2.ExecuteReader();
			while (oleDbDataReader.Read())
			{
				QQItem qQItem2 = new QQItem();
				qQItem2.uin = oleDbDataReader["qq"].ToString();
				IEnumerator enumerator2 = arrayList_0.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					QQItem qQItem3 = (QQItem)enumerator2.Current;
					if (qQItem2.uin.Equals(qQItem3.uin ?? ""))
					{
						qQItem3.is_taoke = "1";
						break;
					}
				}
			}
			oleDbDataReader.Close();
			string_2 = "";
			result = arrayList_0;
		}
		catch (Exception ex)
		{
			string_2 = "出错啦：" + ex.ToString();
			this.method_9();
			result = null;
		}
		return result;
	}
	private void method_5(out string string_2)
	{
		if (!this.method_6("taokeqq", out string_2))
		{
			string string_3 = "CREATE TABLE taokeqq (qq varchar(30) NOT NULL ,  PRIMARY KEY (qq) ) ";
			this.method_7(string_3, out string_2);
		}
	}
	public bool method_6(string string_2, out string string_3)
	{
		bool result;
		try
		{
			string string_4 = "select count(1) from " + string_2;
			new ArrayList();
			this.oleDbCommand_3 = this.method_8(this.oleDbCommand_3, string_4);
			this.oleDbCommand_3.ExecuteReader().Close();
			string_3 = "";
			result = true;
		}
		catch
		{
			string_3 = "";
			result = false;
		}
		return result;
	}
	public bool method_7(string string_2, out string string_3)
	{
		bool result;
		try
		{
			this.oleDbCommand_4 = this.method_8(this.oleDbCommand_4, string_2);
			this.oleDbCommand_4.ExecuteNonQuery();
			string_3 = "";
			result = true;
		}
		catch (Exception ex)
		{
			string_3 = ex.ToString();
			result = false;
		}
		return result;
	}
	public OleDbCommand method_8(OleDbCommand oleDbCommand_6, string string_2)
	{
		if (this.oleDbConnection_0 == null)
		{
			this.method_0();
		}
		if (oleDbCommand_6 == null || oleDbCommand_6.Connection == null || oleDbCommand_6.Connection.State != ConnectionState.Open)
		{
			oleDbCommand_6 = new OleDbCommand(string_2, this.oleDbConnection_0);
			return oleDbCommand_6;
		}
		oleDbCommand_6.CommandText = string_2;
		return oleDbCommand_6;
	}
	public void method_9()
	{
		try
		{
			this.oleDbConnection_0.Close();
			this.oleDbConnection_0.Dispose();
			this.oleDbConnection_0 = null;
		}
		catch
		{
			this.oleDbConnection_0 = null;
		}
	}
}
